<?php

namespace app\api\model\admin\setting;

use app\api\common\model\BaseModel;
use app\api\common\traits\ModelTrait;
use think\db\Query;

class Upload extends BaseModel
{
    use ModelTrait;

    protected $connection = 'mysql';
    /**
     * 数据表主键
     *
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     *
     * @var string
     */
    protected $name = 'admin_uploads';

    //软删除，查询时会自动加上 xxx IS NULL
    use \think\model\concern\SoftDelete;

    // 定义时间戳字段名

    protected string $deleteTime = 'delete_time';

    /**
     * 搜索器
     *
     * @param \think\db\Query $query
     * @param string          $value
     */
    public function searchNameLikeAttr(Query $query, string $value)
    {
        if ($value) {
            $query->whereLike('name', $value . '%');
        }
    }

    public function searchIdInAttr(Query $query, string|array $value)
    {
        if ($value) {
            $query->whereIn('id', $value);
        }
    }

}
